package org.spitter.core.dao.impl;

import javax.persistence.Query;

import org.spitter.core.dao.SpitterDao;
import org.spitter.core.model.Spitter;
import org.springframework.stereotype.Repository;

@Repository
public class SpitterDaoImpl extends EntityJpaDaoImpl<Spitter> implements
		SpitterDao {

	public SpitterDaoImpl() {
		setClazz(Spitter.class);
	}

	@Override
	public Spitter findByUsername(String username) {
		Query q = entityManager.createQuery("from " + this.clazz.getName()
				+ " WHERE username='" + username + "'");
		Spitter spitter;
		try{
			spitter=(Spitter) q.getSingleResult();
		}catch(Exception e ){
			spitter=null;
		}
		return spitter;
	}
}
